<template>
  <a-card :bordered='false' class='card-area'>
    <!-- 查询区域 11111-->
    <div class='table-page-search-wrapper'>
      <a-form layout='inline' :label-col='labelCol' @keyup.enter.native='searchQuery'>
        <a-row :gutter='24'>
          <a-col :md="5" :sm="8">
            <a-form-item label="计划标题">
              <a-input placeholder="请输入计划标题" v-model="queryParam.planTitle"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md='6' :sm='8'>
            <a-form-item label='执行年'>
              <a-input placeholder='请输入执行年' v-model='queryParam.year'></a-input>
            </a-form-item>
          </a-col>
          <span style='float: left;overflow: hidden;' class='table-page-search-submitButtons'>
           <a-col :md='6' :sm='24'>
               <a-button type='primary' @click='searchQuery' icon='search'>查询</a-button>
               <a-button type='primary' @click='searchReset' icon='reload' style='margin-left: 8px'>重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class='table-operator'>
      <a-button @click='handleAdd' type='primary' icon='plus'>新增</a-button>

    </div>

    <!-- table区域-begin -->
    <div>
      <div class='ant-alert ant-alert-info' style='margin-bottom: 16px;'>
        <i class='anticon anticon-info-circle ant-alert-icon'></i>
        <span>已选择</span>
        <a style='font-weight: 600'>
          {{ selectedRowKeys.length }}
        </a>
        <span>项</span>
        <a style='margin-left: 24px' @click='onClearSelected'>清空</a>
      </div>

      <a-table
        ref='table'
        size='middle'
        bordered
        rowKey='id'
        :columns='columns'
        :dataSource='dataSource'
        :pagination='ipagination'
        :loading='loading'
        :rowSelection='{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}'
        @change='handleTableChange'>

        <span slot='action' slot-scope='text, record'>
          <a @click='handleView(record)'>查看</a>
          <a-divider type='vertical' />
          <a @click='handleEdit(record)'>编辑</a>
          <a-divider type='vertical' />
          <a @click="postSubmit(record.id,'确认开始执行此任务？','/ch/interview/plan/sure')">确认开始</a>
          <a-divider type='vertical' />
          <a-dropdown>
            <a class='ant-dropdown-link'>更多 <a-icon type='down' /></a>
                <a-menu slot='overlay'>
                      <a-menu-item>
                        <a-popconfirm title='确定删除吗?' @confirm='() => handleDelete(record.id)'>
                          <a>删除</a>
                        </a-popconfirm>
                      </a-menu-item>
                </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <hHisInterviewPlan-edit-modal ref='modalEdit'  @ok='modalFormOk'></hHisInterviewPlan-edit-modal>
    <hHisInterviewPlan-view-modal ref='modalView' @ok='modalFormOk'></hHisInterviewPlan-view-modal>
    <hHisInterviewPlan-modal ref='modalForm' @ok='modalFormOk'></hHisInterviewPlan-modal>
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import HHisInterviewPlanModal from './modules/HHisInterviewPlanModal'
import HHisInterviewPlanEditModal from './modules/HHisInterviewPlanEditModal'
import HHisInterviewPlanViewModal from './modules/HHisInterviewPlanViewModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { putAction, getAction, postAction } from '@/api/manage'
import { frozenBatch } from '@/api/api'

export default {
  name: 'h_his_interview_planList',
  mixins: [JeecgListMixin],
  components: {
    HHisInterviewPlanModal,
    HHisInterviewPlanViewModal,
    HHisInterviewPlanEditModal
  },
  data() {
    return {
      description: '走访计划管理页面',
      labelCol: { style: { width: '110px' } },
      queryParam: { planType: '2' },
      // 表头
      columns: [
        {
          title: '计划编号',
          align: 'center',
          dataIndex: 'planCode'
        },
        {
          title: '计划标题',
          align: 'center',
          dataIndex: 'planTitle'
        },
        {
          title: '开始日期',
          align: 'center',
          dataIndex: 'startTime'
        },
        {
          title: '结束日期',
          align: 'center',
          dataIndex: 'endTime'
        },

        {
          title: '服务人数',
          align: 'center',
          dataIndex: 'serviceQty'
        },
        {
          title: '执行次数(次/周)',
          align: 'center',
          dataIndex: 'execCount'
        },
        {
          title: '完成执行次数',
          align: 'center',
          dataIndex: 'finishCount'
        },
        {
          title: '执行人',
          align: 'center',
          dataIndex: 'eyName'
        },
        {
          title: '执行状态',
          align: 'center',
          dataIndex: 'taskStatus',
          customRender: function(t, r, index) {
            return t=='1'?"未执行":t=='2'?"执行中":"执行结束";
          }
        },
        {
          title: '创建人员 ',
          align: 'center',
          dataIndex: 'createUser'
        },
        {
          title: ' 创建时间',
          align: 'center',
          dataIndex: 'createTime'
        },
        { title: '操作', dataIndex: 'action', align: 'center', width: 260, scopedSlots: { customRender: 'action' } }
      ],
      url: {
        list: '/ch/interview/plan/list',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    handleEdit: function (record) {
      this.$refs.modalEdit.edit(record);
      this.$refs.modalEdit.title = "编辑";
      this.$refs.modalEdit.disableSubmit = false;
    },
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>